package adapter;

import android.content.Context;
import android.text.SpannableString;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.qianfeng.lingshijia.R;

import java.util.List;

public class MessageListViewAdapter extends BaseAdapter {

	List<String> list;
	Context context;
	private SpannableString ss;

	public MessageListViewAdapter(List<String> list, Context context) {
		this.list = list;
		this.context = context;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh = new ViewHolder();
		if (convertView == null) {
			convertView = View.inflate(context, R.layout.message_layout, null);
			vh.tv = (TextView) convertView.findViewById(R.id.message);
			convertView.setTag(vh);
		}else{
			vh = (ViewHolder) convertView.getTag();
		}
		vh.tv.setText(list.get(position));
		return convertView;
	}

	class ViewHolder {
		TextView tv;
	}

}
